const state = {
	isMobile: true // 默认设备是手机
}

const mutations = {
	IS_MOBILE_SET: (state, isMobile) => {
		state.isMobile = isMobile
	}
} 

const actions = {
	 getInfo({ commit, state },userInfo) {
	    return new Promise((resolve, reject) => {
	      getInfo(state.token, userInfo).then(response => {
	        const { data } = response
	        if (!data) {
	          reject('Verification failed, please Login again.')
	        }
	        const { name, avatar } = data
	
	        commit('SET_NAME', name)
	        commit('SET_AVATAR', avatar)
	        resolve(data)
	      }).catch(error => {
	        reject(error)
	      })
	    })
	  },
}

export default {
	/* 
	 命名空间，调用时才能区别，不同空间的属性方法，例：
	 this.$store.state.app.isMobile
	 this.$store.commit('app/IS_MOBILE_SET')
	 this.$store.dispatch('app/getInfo')
	 */
	namespaced: true, 
	state,
	mutations,
	actions
}